import axios from 'utils/axios.js'

// 获取课程导航数据
export function getCourseNav () {
    return axios.get('/mock/course/nav.json')
}

// 获取课程信息
export function getCourseList () {
    return axios.get('/mock/course/list.json')
}

// 获取课程详情
export function getCourseDetail (courseId) {
    return axios({
        url:'/course/queryCourseById',
        method: 'get',
        params:{
            courseId : courseId
        }
    })
}

// 获取全部的方向
export function getAllDire () {
    return axios({
        url: '/courseType/queryDirect',
        method: 'get'
    })
}

// 获取全部的分类
export function getAllType () {
    return axios({
        url: '/courseType/queryAllChild',
        method: 'get'
    })
}

// 获取全部难度
export function getLevels () {
    return axios({
        url: '/common/getLevel',
        method: 'get'
    })
}

// 获取某个方向下的分类
export function getChild (parentId) {
    return axios({
        url: '/courseType/queryChild',
        method: 'get',
        params: {
            parentId: parentId
        }
    })
}

// 查询课程信息
export function getCourse (params) {
    return axios({
        url:'/course/queryAllByPageForUser',
        method: 'get',
        params:params
    })
}


/**
 * 根据关键字查询课程
 * @param keyword
 */
export function getCourseByKeyWord (params) {
    return axios({
        url:'/es/search/queryCourseByKeyWord',
        method:'get',
        params:params
    })
}

/**
 * 处理历史记录
 * @param params
 */
export function dealHistory (params) {
    return axios({
        url: '/history/dealHistory',
        method: 'post',
        params: params
    })
}


/**
 * 课程添加收藏
 * @param courseId
 */
export function addCollect (courseId) {
    return axios({
        url:'/collect/add',
        method:'post',
        params:{
            courseId:courseId
        }
    })
}


/**
 * 删除收藏
 * @param id
 */
export function deleteCollect (id) {
    return axios({
        url:'/collect/delete',
        method:'delete',
        params:{
            ids:id
        }
    })
}